﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Estate.swfupload
{
    public partial class index : System.Web.UI.Page
    {
        string nextUri = string.Empty;
        string eid = string.Empty;
        string type = string.Empty;
        string typename = string.Empty;
        protected int photocount = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["file_info"] = "";
            }
            nextUri = _Request.GetString("url", "");
            eid = _Request.GetString("id", "0");
            Session["eid"] = eid;
            type = _Request.GetString("type", "");
            Session["type"] = type;
            typename = _Request.GetString("typename", "");
            Session["typename"] = typename;
            photocount = _Request.GetInt("photocount", 3);    // 允许上传的图片量,默认为5张

        }

        protected void btnNext_Click(object sender, ImageClickEventArgs e)
        {
            List<Thumbnail> thumbanil = Session["file_info"] as List<Thumbnail>;
            if (thumbanil == null) 
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script>alert('请上传图片！')</script>", false);
                return;
            }

            //string typename = _Request.GetString("typename", "");//操作类型
           
            //string type = _Request.GetString("type", "");
            //if (type.Equals("1"))
            //{
            //    //if (typename.Equals("estate"))
            //    //{
            //    //    int count = ZLDC.Topo.BLL.Estate.EstatePicBLL.EstateCoutnPic(_Convert.ToInt(eid), _Convert.ToInt(type));
            //    //    //限制上传图片数量
            //    //    if (thumbanil.Count + count > 5)
            //    //    {
            //    //        Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script>alert('同个楼盘上传图片张数不能超过5张！')</script>", false);
            //    //        return;
            //    //    }
            //    //}
            //    //else 
            //    //只限制盘源的,全部制楼盘的
            //    if (typename.Equals("housing"))
            //    {
            //        int count = ZLDC.Topo.BLL.Estate.HuosingPicBLL.HousingCoutnPic(_Convert.ToInt(eid), type);
            //        if (thumbanil.Count + count > 5)
            //        {
            //            Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script>alert('同个楼盘上传图片张数不能超过5张！')</script>", false);
            //            return;
            //        }
            //    }
            //}

            //Response.Redirect(nextUri+"?id="+eid+"&type="+type+"&typename="+typename);
            Response.Redirect(nextUri);

        }
    }
}
